home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d2 / stayres.arc / STAYXIT.340 < prev   
Text File  |  1988-06-27  |  2KB  |  38 lines

  1. {****************************************************************************}
  2. {                       S T A Y X I T   .   I N C                            }
  3. {                                                                            }
  4. {     Separate this file into "StayXIT.320" to provide a "Go-non-Resident"   }
  5. {                   routine or the Stay-Resident Demo.                       }
  6. {                                                                            }
  7. {****************************************************************************}
  8. Procedure Stay_Xit;
  9. {-----------------------------------------------------------------------------}
  10. {  Stay_Xit Check Terminate Keys                                              }
  11. {                                                                             }
  12. {  Clean up the Program ,Free the Environment block, the program segment      }
  13. {  memory and return to Dos. Programs using this routine ,must be the         }
  14. {  last program in memory, else ,a hole will be left causing Dos              }
  15. {  to go GooGoo .                                                             }
  16. {-----------------------------------------------------------------------------}
  17.  
  18.    Begin { Block }
  19.             Rmwin;
  20.             Writeln ('Stay-Resident program Terminating') ;
  21.  
  22.             SaveRegs.Ax := $25 shl 8 + Kybrd_Int;
  23.             SaveRegs.Ds := DOS_IntCS;
  24.             SaveRegs.Dx := DOS_IntIP;  { Reset the Keyboard interrupt addr }
  25.             MsDos(SaveRegs);            { to its original value             }
  26.  
  27.             Saveregs.Ax := $49 shl 8 + 0 ;   { Free Allocated Block function}
  28.             Saveregs.Es := MemW[Cseg:$2C] ;  { Free environment block       }
  29.             MsDos( Saveregs ) ;
  30.  
  31.             Saveregs.Ax := $49 shl 8 + 0 ;    { Free Allocated Block function}
  32.             Saveregs.Es := Cseg ;             { Free Program                 }
  33.             MsDos( Saveregs ) ;
  34.  
  35.             Intr($20,Regs) ;                  { Return to Dos }
  36.  
  37.    End  { StayXit };
  38.